<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上传文件</title>
</head>
<style>

</style>
<body>
    <input onchange="fn()" type="file" id="input">

    <script>
        let xhr=new XMLHttpRequest()
        function fn(){
            let files=document.querySelector('input').files
            //先选择文件
            console.log(files[0])
            //上传文件先进行包装
            let f=new FormData()
            //创建出一个ForData对象
            f.append('file',files[0])
            //通过方法files[0]塞进去
            xhr.open('POST','http://47.116.75.38:8101/common/api/file/upload')
            xhr.send(f)
            xhr.onload=function (){
                console.log(xhr.response)
            }
        }
    </script>
</body>
</html>